﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace place
{
    internal class Travels
    {
        TravelAgency[] travelAgency;
        public Travels(int length)
        {
            travelAgency = new TravelAgency[length];
        }

        public TravelAgency this[int index]
        {
            get
            {
                if (index >= 0 && index < travelAgency.Length)
                {
                    return travelAgency[index];
                }
                // 索引越界
                Console.WriteLine("下标不存在");
                return null;
            }
            set
            {
                this.travelAgency[index] = value;
            }
        }
        public TravelAgency this[string name]
        {
            get
            {
                //forech(数据类型 变量 in 数组，集合，字符串)
                foreach (var v in travelAgency)
                {
                    if (v.Place == name)
                    {
                        return v;
                    }
                }
                Console.WriteLine("暂无");
                return null;
            }
        }
    }
}
